/**
 * Created by yiba0104 on 2017/5/9.
 */
/**
 * Created by yiba0104 on 2017/5/5.
 */

var mysql = require('mysql');

var connection = mysql.createConnection({
    host : 'yibasdkdb-1.cluster-cmd5cf3htxix.us-west-2.rds.amazonaws.com',
    port : 3306,
    user : 'yiba',
    password : 'TGB7ygv!QAZ',
    database : 'sdk',
    charset : 'UTF8_GENERAL_CI',
    debug : false
});
connection.connect();


var query = "INSERT INTO `package_country_num_test` (`creatDate`,`packageName`, `country`, `city`, `num`) VALUES ('2017-03-13', 'woyebuzhidaojiaoshenmemingzi', 'ZH', 'shanghai', 9999)";

for (var i = 0; i < 2000; i++) {
    query += ", ('2017-03-13', 'woyebuzhidaojiaoshenmemingzi', 'ZH', 'shanghai', 9999)"
}

var j = 0;
function save () {
    j++;
    connection.query(query, function(err, result) {
        if (err) {
            throw err;
        }
        console.log(result);
        connection.query("SELECT COUNT(id) FROM `package_country_num_test`;", function(err, result) {
            if (err) {
                throw err;
            } else {
                console.log(result);
            }
        });
        if (j < 2) {
            save(j);
        } else {
            connection.end();
        }
    });
}

save(j);

